﻿using SDDP;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DotNetStar.TheKing.Domain
{
    /// <summary>
    /// 内容评论
    /// </summary>
    /// <seealso cref="SDDP.IEntity{System.Guid}" />
    [Table("ContentComments")]
    public class ContentComment : IEntity<Guid>
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Guid Id { get; set; } = Guid.NewGuid();

        /// <summary>
        /// 正文
        /// </summary>
        [Required]
        public string Body { get; set; }

        /// <summary>
        /// 发布时间
        /// </summary>
        public DateTime PostedTime { get;  set; } = DateTime.Now;
        /// <summary>
        /// 作者Id。
        /// </summary>
        public long AuthorId { get;  set; }
        ///// <summary>
        ///// 作者用户名。
        ///// </summary>
        //[Required,StringLength(30)]
        //public string AuthorUserName { get;private set; }
        /// <summary>
        /// 文档Id。
        /// </summary>
        public long ContentId { get; set; }

        /// <summary>
        /// 设置作者
        /// </summary>
        /// <param name="user">The user.</param>
        public void SetAuthor(User user)
        {
            this.AuthorId = user.Id;
        }
        [NotMapped]
        public User Author { get; set; }
    }
}
